import { Inject, Injectable } from '@nestjs/common';
import { Cron, CronExpression, Interval, Timeout } from '@nestjs/schedule';
import { ArticleViewsService } from '../article-views/article-views.service';


@Injectable()
export class TaskService {

    @Inject(ArticleViewsService)
    private articleViewService: ArticleViewsService

    @Cron(CronExpression.EVERY_DAY_AT_4AM)
    async handleCron() {
        await this.articleViewService.flushRedisToDB()
    }

    // @Interval('task1', 500)
    // async task1() {
    //     console.log('task1')
    // }

    // @Timeout('task2', 1000)
    // async task2() {
    //     console.log('task2')
    // }
}
